<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.model.Goods" %>
<%@ page import="com.dao.GoodsDAO" %>
<%@ page import="com.util.JDBCUtil" %>
<html>
<head>
    <title>药品列表</title>
    <link rel="stylesheet" type="text/css" href="css/listGoods.css">
</head>
<body>
<h2>药品列表</h2>
<form >
    <a href="sousu.jsp"><input type="text" name="sousuo" value="" >
        <input type="submit" name="搜索2" value="搜索"></a>
</form>
<a href="home.jsp">返回主界面</a>
<a href="addGoods.jsp">添加药品</a>
<a href="listorser.jsp">查看订单</a>
<table border="1">
    <tr>
        <th>药品ID</th>
        <th>药品名称</th>
        <th>药品价格</th>
        <th>药品图片</th>
        <th>药品详情</th>
        <th>商品数量</th>
    </tr>
    <%
        GoodsDAO goodsDAO = new GoodsDAO();
        List<Goods> goodsList = goodsDAO.getAllGoods();
        for (Goods goods : goodsList) {
    %>
    <tr>
        <td><%= goods.getId() %></td>
        <td><%= goods.getName() %></td>
        <td><%= goods.getPrice() %></td>
        <td><a href="GoodsDetailServlet?id=<%= goods.getId() %>">
            <img src="<%= request.getContextPath() %>/<%= goods.getImagePath() %>" width="100" height="100"></a></td>
        <td><%= goods.getMark() %></td>
        <td><%= goods.getQuantity() %></td>
        <td>
            <form action="deleteGoods" method="post">
                <input type="hidden" name="id" value="<%= goods.getId() %>">
                <button type="submit">删除</button>
            </form>
            <a href="GoodsDetailServlet?id=<%= goods.getId() %>"><button type="submit">详情</button></a><br>
            <a href="chaxunGoods?id=<%= goods.getId() %>"><button type="submit">修改</button></a><br>
            <a href="CreateOrderServlet?id=<%= goods.getId() %>&action=add">支入/支出</a>
        </td>
    </tr>
    <% } %>
</table>
</body>
</html>
